﻿@model DTcms.Model.BaseModel
@{
    string action = Model.info["action"].ToString();
    ViewBag.Title = "我的积分-" + Model.site.name;
}
@section HeaderContent{

}
<!--当前位置-->
<div class="section">
    <div class="location">
        <span>当前位置：</span>
        <a href="@Html.linkurl("index")">首页</a> &gt;
        <a href="@Html.linkurl("usercenter","index")">会员中心</a>
        <a href="@Html.linkurl("userpoint","list")">我的积分</a>
    </div>
</div>
<!--/当前位置-->
<div class="section clearfix">
    <!--页面左边-->
    @Html.Partial("_ucenter_nav")
    <!--/页面左边-->
    <!--页面左边-->
    <div class="right-auto">
        <div class="bg-wrap" style="min-height:765px;">
            @if (action == "convert")
            {
                <!--积分兑换-->
                <div class="sub-tit">
                    <a class="add" href="javascript:history.go(-1);"><i class="iconfont icon-reply"></i>返回</a>
                    <ul>
                        <li class="selected">
                            <a href="@Html.linkurl("userpoint", "convert")">积分兑换</a>
                        </li>
                        <li>
                            <a href="@Html.linkurl("userpoint", "list")">积分明细</a>
                        </li>
                    </ul>
                </div>

                <div class="form-box">
                    @if (Model.uconfig.pointcashrate == 0)
                    {
                        <div class="msg-box">
                            <i class="iconfont icon-tip"></i>
                            <p>目前的积分兑换功能已被关闭！</p>
                        </div>
                    }
                    else if (Model.userModel.amount < 1)
                    {
                        <div class="msg-box">
                            <i class="iconfont icon-tip"></i>
                            <p>目前您的余额不足，不能使用积分兑换功能！</p>
                        </div>
                    }
                    else
                    {
                        <input id="hideAmount" name="hideAmount" type="hidden" value="@Model.userModel.amount" />
                        <input id="hideCashrate" name="hideCashrate" type="hidden" value="@Model.uconfig.pointcashrate" />
                        <form id="pointForm" name="pointform" url="/api/lisence_ajax/user_point_convert">
                            <dl class="form-group">
                                <dt>账户余额：</dt>
                                <dd>
                                    目前账户积分：<b>@Model.userModel.point</b>分，可用金额：<b>@Model.userModel.amount</b>元
                                </dd>
                            </dl>
                            <dl class="form-group">
                                <dt>兑换说明：</dt>
                                <dd>
                                    积分兑换最少金额为1元，兑换比例为：1元等于 @Model.uconfig.pointcashrate 个积分
                                </dd>
                            </dl>
                            <dl class="form-group">
                                <dt>积分兑换：</dt>
                                <dd>
                                    <input name="txtAmount" id="txtAmount" type="text" class="input" onkeydown="return checkNumber(event);" onchange="numConvert(this);" datatype="n" nullmsg="请输入金额" sucmsg=" " style="width:80px;" />
                                    金额转换成 <strong id="convertPoint">0</strong> 积分
                                </dd>
                            </dl>
                            <dl class="form-group">
                                <dt>验证用户密码：</dt>
                                <dd>
                                    <input name="txtPassword" id="txtPassword" type="password" class="input" datatype="*6-20" nullmsg="请输入密码" sucmsg=" " />
                                </dd>
                            </dl>
                            <dl class="form-group">
                                <dd>
                                    <input id="btnSubmit" name="btnSubmit" type="submit" value="确认兑换" class="submit" />
                                </dd>
                            </dl>
                        </form>
                    }
                </div>
                <input id="turl" name="turl" type="hidden" value="@Html.linkurl("userpoint", "convert")" /><!--存在跳转的URL值-->
                <script type="text/javascript">
                    layui.use(['validform', 'jqueryform'], function () {
                        $("#pointForm").initValidform('#btnSubmit', 1, '#turl');
                    });
                </script>
                <!--/积分兑换-->
            }
            else if (action == "list")
            {
                <!--积分明细-->
                <div class="sub-tit">
                    <a class="add" href="javascript:history.go(-1);"><i class="iconfont icon-reply"></i>返回</a>
                    <ul>
                        <li>
                            <a href="@Html.linkurl("userpoint","convert")">积分兑换</a>
                        </li>
                        <li class="selected">
                            <a href="@Html.linkurl("userpoint","list")">积分明细</a>
                        </li>
                    </ul>
                </div>
                <div class="table-wrap">
                    <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                        <thead>
                            <tr>
                                <th lay-data="{checkbox:true}"></th>
                                <th lay-data="{field:'add_time'}">时间</th>
                                <th lay-data="{field:'remark'}">备注</th>
                                <th lay-data="{field:'value',templet: '#value'}">积分</th>
                                <th lay-data="{templet: '#barDemo'}">操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <script type="text/html" id="value">
                    {{d.value>0?'+':''}}
                    {{d.value}}
                </script>
                <script type="text/html" id="barDemo">
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                </script>
                <input id="turl" type="hidden" value="@Html.linkurl("userpoint","list")" /><!--存在跳转的URL值-->
                <script type="text/javascript">
                    layui.use(['table', 'myaspx'], function () {
                        var table = layui.table, os = layui.myaspx;

                        // 渲染表格
                        os.dataBind('/api/lisence_ajax/get_user_point_list');

                        //监听行工具事件
                        table.on('tool(ltable)', function (obj) {
                            var data = obj.data;
                            if (obj.event === 'del') {
                                layer.confirm('确认操作吗？', function (index) {
                                    cmswh.request("user_point_delete", "POST", { checkId: data.id });
                                    obj.del();
                                    layer.close(index);
                                });
                            }
                        });
                    });
                </script>
                <!--/积分明细-->
            }
        </div>
    </div>
    <!--/页面左边-->
</div>
@section Scripts{

}